﻿using System.ComponentModel.Composition;
using System.Windows.Input;
using VisualWip.Core;
using VisualWip.Core.Interfaces;
using VisualWip.PresentationModel;

namespace VisualWip.TrafficLight
{
    [Export(typeof(IColumnProviderViewModel))]
    public class TrafficLightProviderViewModel : ColumnProviderViewModelBase
    {
        [ImportingConstructor]

        public TrafficLightProviderViewModel(IColumnBuilder columnBuilder)
            : base(columnBuilder)
        {
        }

        public override string ProviderName
        {
            get { return "TrafficLight"; }
        }

        public override string HeaderName
        {
            get { return "TrafficLight"; }
        }

        public override void RegisterViewModels(IViewModelFactory viewModelFactory)
        {
            viewModelFactory.RegisterSettingsViewModel<VisualWip.TrafficLight.TrafficLight, TrafficLightSettingsViewModel>();
            viewModelFactory.RegisterViewModel<VisualWip.TrafficLight.TrafficLight, TrafficLightViewModel>();
        }

        private ICommand _addTrafficLightCommand;
        public ICommand AddTrafficLightCommand
        {
            get
            {
                if (_addTrafficLightCommand == null)
                {
                    _addTrafficLightCommand = new RelayCommand(param => AddTrafficLight());
                }
                return _addTrafficLightCommand;
            }

        }

        private void AddTrafficLight()
        {
            ColumnBuilder.Build<TrafficLight>();
        }

    }
}